2e3b3fe12e430c61372f2ceac69829d267436fff
[openwrt/openwrt.git] /
1 From 8928756d53d5b99dcd18073dc7738b8ebdbe7d96 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Thu, 2 May 2024 10:44:42 +0200
4 Subject: [PATCH 1/6] net: move skb_gro_receive_list from udp to core
5
6 This helper function will be used for TCP fraglist GRO support
7
8 Acked-by: Paolo Abeni <pabeni@redhat.com>
9 Reviewed-by: Eric Dumazet <edumazet@google.com>
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 Reviewed-by: David Ahern <dsahern@kernel.org>
12 Reviewed-by: Willem de Bruijn <willemb@google.com>
13 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
14 ---
15 include/net/gro.h | 1 +
16 net/core/gro.c | 27 +++++++++++++++++++++++++++
17 net/ipv4/udp_offload.c | 27 ---------------------------
18 3 files changed, 28 insertions(+), 27 deletions(-)
19
20 --- a/include/net/gro.h
21 +++ b/include/net/gro.h
22 @@ -439,6 +439,7 @@ static inline __wsum ip6_gro_compute_pse
23 }
24
25 int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb);
26 +int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb);
27
28 /* Pass the currently batched GRO_NORMAL SKBs up to the stack. */
29 static inline void gro_normal_list(struct napi_struct *napi)
30 --- a/net/core/gro.c
31 +++ b/net/core/gro.c
32 @@ -228,6 +228,33 @@ done:
33 return 0;
34 }
35
36 +int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
37 +{
38 + if (unlikely(p->len + skb->len >= 65536))
39 + return -E2BIG;
40 +
41 + if (NAPI_GRO_CB(p)->last == p)
42 + skb_shinfo(p)->frag_list = skb;
43 + else
44 + NAPI_GRO_CB(p)->last->next = skb;
45 +
46 + skb_pull(skb, skb_gro_offset(skb));
47 +
48 + NAPI_GRO_CB(p)->last = skb;
49 + NAPI_GRO_CB(p)->count++;
50 + p->data_len += skb->len;
51 +
52 + /* sk ownership - if any - completely transferred to the aggregated packet */
53 + skb->destructor = NULL;
54 + skb->sk = NULL;
55 + p->truesize += skb->truesize;
56 + p->len += skb->len;
57 +
58 + NAPI_GRO_CB(skb)->same_flow = 1;
59 +
60 + return 0;
61 +}
62 +
63
64 static void napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb)
65 {
66 --- a/net/ipv4/udp_offload.c
67 +++ b/net/ipv4/udp_offload.c
68 @@ -474,33 +474,6 @@ out:
69 return segs;
70 }
71
72 -static int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
73 -{
74 - if (unlikely(p->len + skb->len >= 65536))
75 - return -E2BIG;
76 -
77 - if (NAPI_GRO_CB(p)->last == p)
78 - skb_shinfo(p)->frag_list = skb;
79 - else
80 - NAPI_GRO_CB(p)->last->next = skb;
81 -
82 - skb_pull(skb, skb_gro_offset(skb));
83 -
84 - NAPI_GRO_CB(p)->last = skb;
85 - NAPI_GRO_CB(p)->count++;
86 - p->data_len += skb->len;
87 -
88 - /* sk ownership - if any - completely transferred to the aggregated packet */
89 - skb->destructor = NULL;
90 - skb->sk = NULL;
91 - p->truesize += skb->truesize;
92 - p->len += skb->len;
93 -
94 - NAPI_GRO_CB(skb)->same_flow = 1;
95 -
96 - return 0;
97 -}
98 -
99
100 #define UDP_GRO_CNT_MAX 64
101 static struct sk_buff *udp_gro_receive_segment(struct list_head *head,